package com.contact.util.util.validation;

import java.io.Serializable;

public class ValidationError implements Serializable {

    private static final long serialVersionUID = -7906219996479776540L;

    private final transient String message;
    private final transient Exception exception;

    public ValidationError(String message) {
        this.exception = null;
        this.message = message;
    }

    public ValidationError(Exception exception) {
        this.exception = exception;
        this.message = exception.getMessage();
    }

    public String getMessage() {
        return message;
    }

    public Exception getException() {
        return exception;
    }

    @Override
    public String toString() {
        if (message != null) {
            return message;
        }
        return exception.getMessage();
    }
}
